# -*- coding: utf-8 -*-
# Author: Andeviln
# Date: 2025/01/6
# Version: 1.0.0
# 功能：配置文件，包括数据库配置、日志配置等

import configparser

# EXCEL_FILE_PATH = r'../excel/'  # excel文件夹路径
CONFIG_FILE_PATH = r'../configure/configure.ini'  # 程序配置文件路径

class Config:
    def __init__(self,path=CONFIG_FILE_PATH):
        # 初始化函数，设置配置文件路径
        self.path = path
        self.config = configparser.ConfigParser()
        # 创建ConfigParser对象
        self.config.read(self.path, encoding='utf-8')

        # 读取配置文件，设置编码格式为utf-8
    def get(self,section,key):
        # 获取指定section和key的值
        return self.config.get(section,key)

    def set(self,section,key,value):
        # 设置指定section和key的值
        self.config[section][key] = value
        with open(self.path, 'w', encoding='utf-8') as f:
            self.config.write(f)
        print("配置文件已更新")



if __name__ == '__main__':
    conf = Config()
    print(conf.get('Paths','EXCEL_FILE_PATH'))
    print(conf.get('Paths', 'DATA_FILE_PATH'))
    # conf.set('Paths', 'DD', '12344')